<template>
	<div v-cloak class="aui-wrapper aui-page__iframe">
		<div class="aui-content__wrapper">
			<div class="aui-content">
				<el-card shadow="never" class="aui-card--fill">
					<div class="mod-Djj">
						<el-table v-loading="dataListLoading" :data="dataList" border style="width: 100%;">
							<el-table-column prop="DVC_NO" label="堆垛机" header-align="center" align="center"></el-table-column>
							<!-- <el-table-column prop="statusstr" label="状态" header-align="center" align="center"></el-table-column> -->
							<el-table-column prop="status" label="状态" sortable="custom" header-align="center"
								align="center">
								<template #default="scope">
									<el-tag v-if="scope.row.status == 1" size="small">正常</el-tag>
									<el-tag v-else size="small" type="danger">暂停</el-tag>
								</template>
							</el-table-column>
							<el-table-column label='操作' fixed="right" header-align="center" align="center" width="150">
								<template #default="scope">
									<el-button type="text" size="small" @click="changeDDJStatusFn(scope.row.DVC_NO,'1')">启用</el-button>
									<el-button type="text" size="small" @click="changeDDJStatusFn(scope.row.DVC_NO,'0')">停用</el-button>
								</template>
							</el-table-column>
						</el-table>
					</div>
				</el-card>
			</div>
		</div>
	</div>
</template>

<script>
	import {ref,reactive,onMounted,nextTick} from 'vue';
	import {getDDJ,changeDDJStatus} from '@/network/lswms/WCS/WCS.js';
	import {
		ElMessage
	} from "element-plus";
	export default {
		name: "djj",
		setup(){
			const dataList = ref([]);
			const dataListLoading = ref(false);
			const getDataList =()=>{
				dataListLoading.value = true;
				getDDJ().then((res)=>{
					if (res.code != 0) {
						return ElMessage.error(res.msg);
						dataListLoading.value = false;
					}
					dataList.value = res.data;
					dataListLoading.value = false;
				})
			}
			onMounted(()=>{
				getDataList();
			})
			
			const changeDDJStatusFn =(DVC_NO,status)=>{
				let data = {DVC_NO:DVC_NO.toString(),status}
				changeDDJStatus(data).then((res)=>{
					if(res.code !=0){
						return ElMessage.error(res.msg);
					}
					getDataList();
				})
			}
			
			return {
				dataList,
				getDataList,
				changeDDJStatusFn,
				dataListLoading
			}
		}
	}
	

</script>

<style>
</style>
